<?php
#define('SMARTY_SPL_AUTOLOAD', 1);
require BASEPATH."Libs".DIRECTORY_SEPARATOR."Smarty".DIRECTORY_SEPARATOR."libs".DIRECTORY_SEPARATOR."Smarty.class.php";
/**
*Derives the Smary class to support templates.
*@package Html
*@author Willy Gardiol <willy@gardiol.org>
*@version 1.0
*/
class HtmlTemplate extends Smarty
{
	private $template = false;
	public function __construct( $template, $attributes = array() )
	{
		parent::__construct();
		// TODO: enable caching!!!
		$this->caching = false;

		foreach ( $attributes as $k => $v )
			$this->assign($k, $v);
		$this->template = $template;
		$this->compile_dir = BASEPATH.'..'.DIRECTORY_SEPARATOR.'templates_c';
		$this->cache_dir = BASEPATH.'..'.DIRECTORY_SEPARATOR.'cache';
		$this->plugins_dir = BASEPATH."plugins".DIRECTORY_SEPARATOR."Smarty";

		# Force use of core, box or brick resources
		$this->template_dir = "";
	}
	private function PrepareTemplate()
	{
		$this->assign("auth", CoreAuth::Authorize() );
// TODO: put this back in place...
#		require_once BASEPATH."Libs".DIRECTORY_SEPARATOR."Smarty".DIRECTORY_SEPARATOR."libs".DIRECTORY_SEPARATOR."plugins".DIRECTORY_SEPARATOR."outputfilter.trimwhitespace.php";
#		$this->register_outputfilter("smarty_outputfilter_trimwhitespace");
	}
	public function DrawHtml()
	{
		$this->PrepareTemplate();
		$this->display($this->template);
	}
	public function FetchHtml()
	{
		$this->PrepareTemplate();
		return $this->fetch($this->template);
	}
}
?>